<%@page import="com.shsh.safemanage.util.Util"%>
<%@page import="com.shsh.safemanage.model.Problem"%>
<%@page import="java.util.List"%>
<%@page import="com.shsh.safemanage.model.PostcheckMonthSanweiReport"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.dao.PostCheckDao"%>
<%@page import="com.shsh.safemanage.action.ActionCreator"%>
<%@page import="com.shsh.safemanage.action.PostcheckReportAction"%>
<%@page import="com.shsh.safemanage.model.User"%>
<%@page import="com.shsh.safemanage.util.Constants"%>
<%@page import="com.shsh.safemanage.util.RequestUtil"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%
	{

session.removeAttribute(Constants.SESSION_POSTCHECK_DEPART_MONTH_SANWEI_REPORT);

User sessionUser = (User)session.getAttribute(Constants.SESSION_USER);

Integer year = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_YEAR, 0);
Integer month = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_MONTH, 0);

PostcheckReportAction reportAction = ActionCreator.createPostcheckReportAction();

PostCheckDao thePostcheckDao = DaoCreator.createPostCheckDao();

PostcheckMonthSanweiReport report = thePostcheckDao.getDepartMonthSanweiReport(year, month, sessionUser.getDepartment1ID());
%>
<div class="hider" id="hider">
	<span>&nbsp;</span>
</div>
<div class="position">
	<img src="images/position2.jpg" style="padding: 7px 9px; float: left;" />当前位置：上海高桥分公司问题管理平台 &gt;&gt; 岗检汇总统计 &gt;&gt;公司<%=month %>月岗检“三违”现象问题汇总
</div>
<div class="tt">《公司岗检“三违”现象问题汇总》</div>
<%
if(report!=null){
%>
<!-- 上月汇总表已经固化 -->

<div class="content" style="">
	<div style="float:left;padding-left:45%;padding-top:80px;font-size:14px;font-weight:bold;font-family:'微软雅黑','宋体';">无需填报</div>
</div>
<%
	return;
}

boolean isSuccess = reportAction.generateDepartMonthSanweiReport(request);
if(isSuccess) {
	report = (PostcheckMonthSanweiReport)request.getAttribute(Constants.REQUEST_ATTRIBUTE_POSTCHECK_DEPART_MONTH_SANWEI_REPORT);
}
%>

<div class="content" style="">
	<div style="width:97%;margin-left: 10px;font-weight:bold;font-size:20; ">
	<span style="margin-right: 20px;float:right;">
		月份：<%=report.getYear() %>年<%=report.getMonth() %>月
	</span>
	</div>
	
	<table border="1" width="99%" style="align:center; margin-left: 6px">
		<tr>
		<td style="text-align:center;width:4%;" class="td3">
		序号
		</td>
		<td style="text-align:center;width:10%;" class="td3">
		处室
		</td>
		<td style="text-align:center;width:10%;" class="td3">
		岗检管理线条
		</td>
		<td style="text-align:center;width:10%;" class="td3">
		作业部
		</td>
		<td style="text-align:center;width:10%;" class="td3">
		装置
		</td>
		<td style="text-align:center;width:6%;" class="td3">
		扣分值
		</td>
		<td style="text-align:center;" class="td3">
		扣分原因
		</td>
		<td style="text-align:center;width:12%;" class="td3">
		是否“三违”现象
		</td>
		</tr>
<%
List<Problem> postcheckList = report.getPostcheckList();
for(int i=0;i<postcheckList.size();i++) {
	Problem p = postcheckList.get(i);
%>
		<tr>
			<td style="text-align:center;" >
			<%=i+1 %>
			</td>
			<td style="padding-left:5px;padding-right:5px;text-align:center;">
			<%=Util.getDisplay(p.getWriterDepartment1Name(), "&nbsp;") %>
			</td>
			<td style="padding-left:5px;padding-right:5px;text-align:center;">
			<%=Util.getDisplay(p.getPostcheckName(), "&nbsp;") %>
			</td>
			<td style="padding-left:5px;padding-right:5px;text-align:center;">
			<%=Util.getDisplay(p.getDepartment1Name(), "&nbsp;") %>
			</td>
			<td style="padding-left:5px;padding-right:5px;text-align:center;">
			<%=Util.getDisplay(p.getEquipmentName(), "&nbsp;") %>
			</td>
			<td style="padding-left:5px;padding-right:5px;text-align:center;">
			<%=p.getGrade()==null?"&nbsp;":Util.formatGrade(p.getGrade()) %>
			</td>
			<td style="padding-left:5px;padding-right:5px;text-align:left;">
			<%=Util.getDisplay(p.getProblemContent(), "&nbsp;") %>
			</td>
			<td style="padding-left:5px;padding-right:5px;text-align:center;">
				<input id="SanweiTrue<%=p.getId() %>" name="SanweiTrue<%=p.getId() %>" type="checkbox" value="true"    checked="checked" onclick="checkSanweiTrue(<%=p.getId() %>)"/><label for="SanweiTrue<%=p.getId() %>">是</label>
				<input id="SanweiFalse<%=p.getId() %>" name="SanweiFalse<%=p.getId() %>" type="checkbox" value="false" onclick="checkSanweiFalse(<%=p.getId() %>)" /><label for="SanweiFalse<%=p.getId() %>">否</label>
			</td>
		</tr>
<%
}
%>
	<tr>
		<td class="td1" colspan="10" >
				<span style="margin-left: 30px; font-weight: bold">反馈信息：</span>
				<br />
				<div id="feedbackProcessMethodDiv">
				<%@include file="/postcheck/report/write_depart_month_sanwei_method.jsp" %>
				</div>				
			</td>
	</tr>
		<tr>
		<td class="td1" height="35" colspan="10" style="padding-top:15px;padding-bottom:15px;">
			<input type="button" style="margin-left: 45%;" value="提 交" onclick="writePostcheckMonthSanweiReport()" />
			<input type="button" style="margin-left: 30px;" value="取 消" onclick="cancelWrite()" />
		</td>
		</tr>
	</table>
</div>

<script type="text/javascript">
function createParamJSON(){
	var paramJSON = '';	
	$('input:checkbox').each(function(){
		var paramName = "'" + this.name + "'" ;
		var paramValue =  "'" + $(this).attr('checked') + "'";
		paramJSON =  paramJSON + "," + paramName + ":" + paramValue;
	});
	
	paramJSON = paramJSON.substring(1);
	paramJSON = '{' + paramJSON + '}';

	return paramJSON;
}

function writePostcheckMonthSanweiReport(){
	var processMethod = 0;
	var processRadio1 = document.getElementById('processRadio1');
	var processRadio3 = document.getElementById('processRadio3');
	if (processRadio3 != null && processRadio3.checked) {
		processMethod = 3;
	} else 	if (processRadio1 != null && processRadio1.checked) {
		processMethod = 1;
	}

	var paramJSON = createParamJSON();

	if ($.dialog.confirm('您确定提交此报告吗？', function(){
		openWaitingDialog('waitingDialog');
		$.ajax({
			type:'post',
			url:'<%=request.getContextPath()%>/postcheck/report/write_depart_month_sanwei_process.jsp',
			data:{
				processMethod: processMethod,
				transferID: '',
				feedback: '',
				problemTitle: '《岗检“三违”现象问题汇总》',
				paramJSON: paramJSON
			},
			success:function(data,state,xmlhttp){
				var obj = null;
				try {
					obj = eval('(' + data + ')');
				} catch (e) {
				}
				if (typeof(obj.isSuccess) != 'undefined') {
					closeWaitingDialog('waitingDialog');
					if (obj.isSuccess == 'true') {
						$.dialog('报告填报成功！', function() { loadPageSection('<%=request.getContextPath()%>/user_infor.jsp', 'mainContentDiv'); });
					} else {
						$.dialog.alert(obj.error);
					}
				}
			}
		});
	}, function(){}));
}
function checkSanweiTrue(problemID) {
	var trueID = '#SanweiTrue' + problemID;
	var falseID = '#SanweiFalse' + problemID;
	if($(trueID).attr('checked') == true){
		$(falseID).attr('checked', false);
	}
}

function checkSanweiFalse(problemID){
	var trueID = '#SanweiTrue' + problemID;
	var falseID = '#SanweiFalse' + problemID;
	if($(falseID).attr('checked') == true){
		$(trueID).attr('checked', false);
	}	
}

function cancelWrite(){
	if ($.dialog.confirm('您确定取消提交此报告吗？', function(){
		loadPageSection('<%=request.getContextPath()%>/postcheck/report/write_depart_month_sanwei_cancel.jsp', 'mainContentDiv');
	}, function(){}));	
}

function chooseProcessMethod(method) {
	//empty.
	//convertProblem();
}
</script>
<%
}
%>